import * as orderApi from '@/api/order-api'

export default {
    methods: {
        /**
         * 手动发起扣款
         */
        async shoudongkoukuan({
            customerId,
            signOrderBillId,
            amount,
        }) {
            try {
                const result = await orderApi.deduction({
                    customerId: customerId, // "客户id",
                    signOrderBillId: signOrderBillId, // "扣款订单id",
                    amount: amount, // "扣款金额"
                });
                if (result.code == 200) {
                    this.showkoukuan = false;
                    uni.navigateBack();
                    uni.$emit('shoudongkoukuan');
                    return;
                }
                throw new Error(result.msg);
            } catch (error) {
                const title = error?.msg || error?.message || error || '网络错误';
                // uni.showToast({ title, icon: 'error' });
                this.$refs.uToast.show({
                    type: 'error',
                    icon: false,
                    message: title,
                })
            }
        },
    },
}